package com.campus.customer.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.campus.common.bean.common.Resp;
import com.campus.customer.entity.Category;
import com.campus.customer.service.CategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 商户分类表 前端控制器
 * </p>
 *
 * @author ZhaoYuJie
 * @since 2025-04-02
 */
@Api(tags = "分类管理")
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    @ApiOperation("获取分类列表")
    @GetMapping("/list")
    public Resp<List<Category>> list() {
        List<Category> list = categoryService.list(Wrappers.<Category>lambdaQuery()
                .eq(Category::getStatus, true)
                .orderByAsc(Category::getSort));
        return Resp.success(list);
    }
}
